const CopyWebpackPlugin = require('copy-webpack-plugin');
const {
  CleanWebpackPlugin
} = require('clean-webpack-plugin');
const CssMinimiserWebpackPlugin = require('css-minimizer-webpack-plugin');
const MiniCssExtractWebpackPlugin = require('mini-css-extract-plugin');
const TerserWebpackPlugin = require('terser-webpack-plugin');


module.exports = {
  mode: 'production',
  devtool: false,
  optimization: {
    splitChunks: {
      chunks: 'all',
    },
    minimize: true,
    minimizer: [
      new CssMinimiserWebpackPlugin(),
      new TerserWebpackPlugin()
    ]
  },
  plugins: [
    new CopyWebpackPlugin({
      patterns: [{
        from: 'public',
        globOptions: {
          ignore: ['**/index.html']
        }
      }]
    }),
    new MiniCssExtractWebpackPlugin({
      filename: 'css/name.[hash:8].css'
    }),
    new CleanWebpackPlugin()
  ]
}